﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DreamBox.Admin.User
{
    public partial class GroupUpdate : BLL.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["GID"] != null)
                {
                    DAL.PSelect ps = new DAL.PSelect();
                    DataTable dt = ps.Select("dbox_UserGroup","*","GID="+Request.QueryString["GID"]);
                    if (dt.Rows.Count > 0)
                    {
                        GroupID.Text = dt.Rows[0]["GID"].ToString();
                        GroupName.Text = dt.Rows[0]["GroupName"].ToString();
                        boxStatus.Checked = bool.Parse(dt.Rows[0]["IsStatus"].ToString());
                    }
                }
            }
        }
        protected void btnPost_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["GID"] != null)
            {
                Model.Admin.UserGroup m = new Model.Admin.UserGroup();
                m.GID = int.Parse(GroupID.Text.Trim());
                m.GroupName = GroupName.Text;
                m.IsStatus = boxStatus.Checked;

                DAL.Admin.UserGroup group = new DAL.Admin.UserGroup();
                if (group.Update(m))
                {
                    BLL.Admin.Tips.DetailedTips(this, "更新成功", "/User/GroupList.aspx", "1");
                }
            }
        }
    }
}